package com.kit.data.kitopeso.tools;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.viewbinding.ViewBinding;
import androidx.viewpager.widget.ViewPager;


import com.bumptech.glide.Glide;
import com.kit.data.kitopeso.R;
import com.kit.data.kitopeso.adapter.GenderPagerAdapter;
import com.kit.data.kitopeso.adapter.ValueAdapter;
import com.kit.data.kitopeso.base.BaseBindingPopup;
import com.kit.data.kitopeso.databinding.KitoBirthPopBinding;
import com.kit.data.kitopeso.databinding.KitoCardItemBinding;
import com.kit.data.kitopeso.databinding.KitoCardPopBinding;
import com.kit.data.kitopeso.databinding.KitoDeleteUserPopBinding;
import com.kit.data.kitopeso.databinding.KitoGenderPopBinding;
import com.kit.data.kitopeso.databinding.KitoSelectPopBinding;
import com.kit.data.kitopeso.net.PU;
import com.kit.data.kitopeso.obj.KitoValueInfo;
import com.kit.data.kitopeso.obj.KitoWalletChannel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;

public class PopUtils {

    @SuppressLint("MissingInflatedId")
    public static void showSelectPop(Activity context, View anchorView, List<KitoValueInfo> list, int i, int j, PopClickInterface onPopClickInterface) {


        LayoutInflater inflater = LayoutInflater.from(context);


        final BaseBindingPopup<ViewBinding> popWindow = getPopupWindow(context, KitoSelectPopBinding.inflate(inflater));

        KitoSelectPopBinding binding = (KitoSelectPopBinding) popWindow.binding;

        ValueAdapter valueAdapter = new ValueAdapter(context, list);
        binding.listView.setAdapter(valueAdapter);


        BarUtils.setNavigationBarColor(context, android.R.color.white);

        popWindow.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);

        if (list.size() >= 10) {
            binding.listView.setTMeasure(false);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ResUtils.d(R.dimen.dp_300));
            layoutParams.topMargin = ResUtils.d(R.dimen.dp_16);
            layoutParams.bottomMargin = ResUtils.d(R.dimen.dp_16);
            binding.listView.setLayoutParams(layoutParams);
        } else {
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            layoutParams.topMargin = ResUtils.d(R.dimen.dp_16);
            layoutParams.bottomMargin = ResUtils.d(R.dimen.dp_16);
            binding.listView.setLayoutParams(layoutParams);
        }


        binding.listView.setOnItemClickListener((parent, view, position, id) -> {
            popWindow.dismiss();
            KitoValueInfo valueBean = list.get(position);
            if (onPopClickInterface != null) {
                if (j == 0) {
                    onPopClickInterface.onClickListener(valueBean.getTitle(), valueBean.getValue(), i, position);
                } else {
                    onPopClickInterface.onClickListener(valueBean.getTitle(), valueBean.getValue(), i, j);
                }
            }
        });
        binding.tvRoot.setOnClickListener(v -> popWindow.dismiss());

    }

    @SuppressLint("InflateParams")
    public static void showGenderPop(Activity context, View anchorView, List<KitoValueInfo> list, PopClickInterface onPopClickInterface) {


        List<View> viewList;

        GenderPagerAdapter pagerAdapter;

        LayoutInflater inflater = LayoutInflater.from(context);


        final BaseBindingPopup<ViewBinding> popWindow = getPopupWindow(context, KitoGenderPopBinding.inflate(inflater));

        KitoGenderPopBinding binding = (KitoGenderPopBinding) popWindow.binding;


        viewList = new ArrayList<>();

        View view1 = LayoutInflater.from(context).inflate(R.layout.kito_gender_item, null);
        View view2 = LayoutInflater.from(context).inflate(R.layout.kito_gender_item, null);

        TextView tvTitle1 = view1.findViewById(R.id.tvTitle);
        TextView tvTitle2 = view2.findViewById(R.id.tvTitle);
        ImageView tvIcon1 = view1.findViewById(R.id.tvIcon);
        ImageView tvIcon2 = view2.findViewById(R.id.tvIcon);

        tvTitle1.setText(list.get(0).getTitle());
        tvTitle2.setText(list.get(1).getTitle());
        tvIcon1.setImageResource(R.drawable.kito_gender_selector1);
        tvIcon2.setImageResource(R.drawable.kito_gender_selector2);

        view1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);
                binding.viewPager.setCurrentItem(0);
            }
        });
        view2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);
                binding.viewPager.setCurrentItem(1);
            }
        });

        viewList.add(view1);
        viewList.add(view2);

        getViewScale(viewList, 0);


        binding.viewPager.setPageMargin(0);
        pagerAdapter = new GenderPagerAdapter(viewList);
        binding.viewPager.setAdapter(pagerAdapter);
        binding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                getViewScale(viewList, position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

        binding.tvBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);
                onPopClickInterface.onClickListener("", "", 0, binding.viewPager.getCurrentItem());
                popWindow.dismiss();
            }
        });

        popWindow.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);

        binding.getRoot().setOnClickListener(v -> popWindow.dismiss());

    }

    static void getViewScale(List<View> viewList, int position) {
        for (int i = 0; i < viewList.size(); i++) {
            View view = viewList.get(i);
            TextView tvTitle = view.findViewById(R.id.tvTitle);
            ImageView tvDown = view.findViewById(R.id.tvDown);
            ImageView tvIcon = view.findViewById(R.id.tvIcon);
            ImageView tvUp = view.findViewById(R.id.tvUp);
            if (position != i) {
                tvTitle.setVisibility(View.GONE);
                tvDown.setVisibility(View.GONE);
                tvUp.setVisibility(View.GONE);
                tvIcon.setSelected(false);
            } else {
                tvTitle.setVisibility(View.VISIBLE);
                tvDown.setVisibility(View.INVISIBLE);
                tvUp.setVisibility(View.INVISIBLE);
                tvIcon.setSelected(true);
            }

            if (i != position) {
                view.setScaleX(0.8f);
                view.setScaleY(0.8f);
            } else {
                view.setScaleX(1f);
                view.setScaleY(1f);
            }

        }
    }

    public static void showBirthPop(Activity context, View anchorView, PopClickInterface1 onPopClickInterface) {


        LayoutInflater inflater = LayoutInflater.from(context);


        final BaseBindingPopup<ViewBinding> popWindow = getPopupWindow(context, KitoBirthPopBinding.inflate(inflater));

        KitoBirthPopBinding binding = (KitoBirthPopBinding) popWindow.binding;


        final int[] currentYear = {Calendar.getInstance().get(Calendar.YEAR)};
        final int[] currentMonth = {Calendar.getInstance().get(Calendar.MONTH) + 1};
        final int[] currentDay = {Calendar.getInstance().get(Calendar.DAY_OF_MONTH)};

        List<String> years = new ArrayList<>();
        List<String> days = new ArrayList<>();

        for (int i = 0; i < 31; i++) {
            String d;
            if (i < 9) {
                d = "0" + (i + 1);
            } else {
                d = (i + 1) + "";
            }
            days.add(d);
        }

        String[] monthArry = context.getResources().getStringArray(R.array.data_arry);
        List<String> months = new ArrayList<>(Arrays.asList(monthArry));

        int cout = 65 - 18;
        int min = currentYear[0] - 65;
        for (int i = 0; i <= cout; i++) {
            String d = (min + i) + "";
            years.add(d);
        }


        binding.tvDate1.setData(days);
        final String[] dayDate = {days.get(0)};
        binding.tvDate1.setSelected("01");

        binding.tvDate2.setData(months);
        final String[] monthDate = {months.get(0)};
        binding.tvDate2.setSelected(0);

        binding.tvDate3.setData(years);
        final String[] yearDate = {years.get(years.size() - 1)};
        binding.tvDate3.setSelected("2007");


        binding.tvColse.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);
                popWindow.dismiss();
            }
        });
        binding.tvBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ViewUtils.viewScale(v);

                yearDate[0] = years.get(binding.tvDate3.getmCurrentSelected());
                monthDate[0] = months.get(binding.tvDate2.getmCurrentSelected());
                dayDate[0] = days.get(binding.tvDate1.getmCurrentSelected());

                currentYear[0] = Calendar.getInstance().get(Calendar.YEAR);
                currentMonth[0] = Calendar.getInstance().get(Calendar.MONTH) + 1;
                currentDay[0] = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);

                int xDay;
                int xMonth = 0;
                String xDay1;
                String xMonth1;
                String xMonth2;
                int xYear = Integer.parseInt(yearDate[0]);


                if (dayDate[0].startsWith("0")) {
                    xDay = Integer.parseInt(dayDate[0].replace("0", ""));
                } else {
                    xDay = Integer.parseInt(dayDate[0]);
                }
                xDay1 = dayDate[0];

                xMonth1 = monthDate[0];

                for (int i = 0; i < monthArry.length; i++) {
                    if (xMonth1.equals(monthArry[i])) {
                        xMonth = i + 1;
                        break;
                    }
                }

                if (xMonth < 10) {
                    xMonth2 = "0" + xMonth;
                } else {
                    xMonth2 = "" + xMonth;
                }


                if ((xYear == currentYear[0] && xMonth > currentMonth[0]) || (xYear == currentYear[0] && xMonth == currentMonth[0] && xDay > currentDay[0])) {
                    Toast.makeText(context, context.getResources().getString(R.string.birth_error1), Toast.LENGTH_LONG).show();
                    return;
                }
                int tDay = getMonthOfDay(xYear, xMonth);
                LogUtil.e("me", "xDay->" + xDay + ",tDay->" + tDay + ",xMonth->" + xMonth + ",xYear->" + xYear);
                if (xDay > tDay) {
                    Toast.makeText(context, context.getResources().getString(R.string.birth_error2), Toast.LENGTH_LONG).show();
                    return;
                }

                popWindow.dismiss();

                if (onPopClickInterface != null) {
                    onPopClickInterface.onClickListener(xDay1 + "/" + xMonth1 + "/" + xYear, xYear + "-" + xMonth2 + "-" + xDay1);
                }

            }
        });

        popWindow.setOnDismissListener(() -> {
            BarUtils.setNavigationBar(context, true);
        });

        BarUtils.setNavigationBarColor(context, android.R.color.white);

        popWindow.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);

        binding.getRoot().postDelayed(() -> {
            BarUtils.setNavigationBar(context, false);
            BarUtils.setNavigationBarColor(context, android.R.color.white);
        }, 300);


    }

    public static int getMonthOfDay(int year, int month) {
        int day;
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            day = 29;
        } else {
            day = 28;
        }
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                return 31;
            case 4:
            case 6:
            case 9:
            case 11:
                return 30;
            case 2:
                return day;

        }
        return 0;
    }


    @SuppressLint("SetTextI18n")
    public static void showBindCardPop(Activity context, View anchorView, List<KitoWalletChannel> infoList, int cout, PopClickInterface2 onPopClickInterface) {


        LayoutInflater inflater = LayoutInflater.from(context);


        final BaseBindingPopup<ViewBinding> popWindow = getPopupWindow(context, KitoCardPopBinding.inflate(inflater));

        KitoCardPopBinding binding = (KitoCardPopBinding) popWindow.binding;

        binding.tvIndicate.removeAllViews();

        List<View> viewList = new ArrayList<>();

        int tag = 0;

        for (int i = 0; i < cout; i++) {
            View indicateView = new View(context);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(context.getResources().getDimensionPixelSize(R.dimen.dp_8), context.getResources().getDimensionPixelSize(R.dimen.dp_8));
            if (binding.tvIndicate.getChildCount() > 0) {
                layoutParams.leftMargin = context.getResources().getDimensionPixelSize(R.dimen.dp_6);
                indicateView.setBackground(ResUtils.de(R.drawable.indicate_un_selector));
            } else {
                indicateView.setBackground(ResUtils.de(R.drawable.indicate_selector));
            }
            indicateView.setLayoutParams(layoutParams);
            binding.tvIndicate.addView(indicateView);

            KitoWalletChannel item = infoList.get(i);
            KitoCardItemBinding binding1 = KitoCardItemBinding.inflate(inflater);
            Glide.with(binding1.tvIcon.getContext()).load(item.getLogo()).placeholder(R.color.placeholder_icon).into(binding1.tvIcon);

            LogUtil.e("me", item.getDesc() + "<-item.getLogo()->" + item.getLogo());

            binding1.tvTitle.setText(item.getDesc());

            if (tag == 0) {
                binding1.tvRoot.setBackground(ResUtils.de(R.drawable.kito_bind_card_bg1));
            } else if (tag == 1) {
                binding1.tvRoot.setBackground(ResUtils.de(R.drawable.kito_bind_card_bg2));
            } else if (tag == 2) {
                binding1.tvRoot.setBackground(ResUtils.de(R.drawable.kito_bind_card_bg3));
            } else if (tag == 3) {
                binding1.tvRoot.setBackground(ResUtils.de(R.drawable.kito_bind_card_bg4));
            }
            tag = tag + 1;
            if (tag > 3) {
                tag = 0;
            }

            if (0 == i) {
                binding1.tvRoot.setSelected(true);
                binding1.tvTitle.setSelected(true);
                binding1.getRoot().setScaleX(1f);
                binding1.getRoot().setScaleY(1f);
            } else {
                binding1.tvRoot.setSelected(false);
                binding1.tvTitle.setSelected(false);
                binding1.getRoot().setScaleX(0.8f);
                binding1.getRoot().setScaleY(0.8f);
            }

            viewList.add(binding1.getRoot());
        }


        binding.tvInput1.setType(PU.P90 + "_1");
        binding.tvInput2.setType(PU.P90 + "_2");

        binding.tvInput1.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                binding.tvHit.setVisibility(View.GONE);
                binding.tvInput1.setSelected(false);
                binding.tvInput2.setSelected(false);
                if (!TextUtils.isEmpty(s)) {
                    binding.tvBtn.setSelected(true);
                } else {
                    binding.tvBtn.setSelected(false);
                }
            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

        binding.tvHit.setVisibility(View.GONE);


        GenderPagerAdapter adater = new GenderPagerAdapter(viewList);
        binding.viewPager.setPageMargin(0);
        binding.viewPager.setAdapter(adater);
        binding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                int childCount = binding.tvIndicate.getChildCount();
                for (int i = 0; i < childCount; i++) {
                    View childView = binding.tvIndicate.getChildAt(i);
                    if (position == i) {
                        childView.setBackground(ResUtils.de(R.drawable.indicate_selector));
                    } else {
                        childView.setBackground(ResUtils.de(R.drawable.indicate_un_selector));
                    }
                }
                for (int i = 0; i < viewList.size(); i++) {
                    View view = viewList.get(i);
                    View childView = view.findViewById(R.id.tvRoot);
                    TextView title = view.findViewById(R.id.tvTitle);
                    if (position == i) {
                        childView.setSelected(true);
                        title.setSelected(true);
                    } else {
                        childView.setSelected(false);
                        title.setSelected(false);
                    }
                    if (i != position) {
                        view.setScaleX(0.8f);
                        view.setScaleY(0.8f);
                    } else {
                        view.setScaleX(1f);
                        view.setScaleY(1f);
                    }
                }


            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });


        binding.tvBtn.setOnClickListener(v -> {
            if (binding.tvBtn.isSelected()) {
                ViewUtils.viewScale(v);
                PU.userBuriedPoint(PU.P91, "");
                if (onPopClickInterface != null) {
                    String phone = binding.tvInput1.getText().toString();
                    String phone1 = binding.tvInput2.getText().toString();
                    if (TextUtils.isEmpty(phone) || TextUtils.isEmpty(phone1)) {
                        binding.tvHit.setText(context.getResources().getString(R.string.bind_card_toast1));
                        binding.tvHit.setVisibility(View.VISIBLE);
                        binding.tvInput1.setSelected(true);
                        binding.tvInput2.setSelected(true);
                        return;
                    }
                    if (!PhoneUtils.isPhoneNumber(phone)) {
                        binding.tvHit.setVisibility(View.VISIBLE);
                        binding.tvHit.setText(context.getResources().getString(R.string.bind_card_toast2));
                        binding.tvInput1.setSelected(true);
                        binding.tvInput2.setSelected(true);
                        return;
                    }
                    if (!phone.equals(phone1)) {
                        binding.tvHit.setText(context.getResources().getString(R.string.bind_card_toast3));
                        binding.tvHit.setVisibility(View.VISIBLE);
                        binding.tvInput1.setSelected(true);
                        binding.tvInput2.setSelected(true);
                        return;
                    }
                    binding.tvHit.setVisibility(View.GONE);
                    binding.tvInput1.setSelected(false);
                    binding.tvInput2.setSelected(false);
                    int position = binding.viewPager.getCurrentItem();
                    KitoWalletChannel info = infoList.get(position);
                    onPopClickInterface.onClickListener(info, phone);
                }
                popWindow.dismiss();
            }
        });


        BarUtils.setNavigationBarColor(context, android.R.color.white);

        popWindow.setOnDismissListener(() -> BarUtils.setNavigationBar(context, true));

        popWindow.setFocusable(true);
        popWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);

        popWindow.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);

        binding.tvBtn.postDelayed(() -> {
            BarUtils.setNavigationBar(context, false);
            BarUtils.setNavigationBarColor(context, android.R.color.white);
        }, 300);


        binding.getRoot().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                popWindow.dismiss();
            }
        });

        PU.userBuriedPoint(PU.P88, "");


    }

    public static TextView showDeleteUserPop(Activity context, View anchorView, PopClickInterface onPopClickInterface) {


        LayoutInflater inflater = LayoutInflater.from(context);


        final BaseBindingPopup<ViewBinding> popWindow = getPopupWindow(context, KitoDeleteUserPopBinding.inflate(inflater));

        KitoDeleteUserPopBinding binding = (KitoDeleteUserPopBinding) popWindow.binding;

        binding.tvCancel.setOnClickListener(v -> {
            ViewUtils.viewScale(v);
            popWindow.dismiss();
            if (onPopClickInterface != null) {
                onPopClickInterface.onClickListener("0", "", 0, 0);
            }
        });
        binding.tvOk.setOnClickListener(v -> {
            if (binding.tvOk.isSelected()) {
                ViewUtils.viewScale(v);
                popWindow.dismiss();
                if (onPopClickInterface != null) {
                    onPopClickInterface.onClickListener("1", "", 0, 0);
                }
            }
        });

        BarUtils.setNavigationBarColor(context, android.R.color.white);

        popWindow.setOnDismissListener(() -> BarUtils.setNavigationBar(context, true));

        popWindow.setFocusable(true);
        popWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);

        popWindow.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);

        return binding.tvOk;

    }

    //    public static void showHelpPop(Activity activity, View anchorView) {
//        LayoutInflater inflater = LayoutInflater.from(activity);
//
//        final BaseBindingPopup<ViewBinding> popWindow = getPopupWindow(activity, TurningHelpPopBinding.inflate(inflater));
//        TurningHelpPopBinding binding = (com.xin.data.turning.databinding.TurningHelpPopBinding) popWindow.binding;
//        binding.tvRoot.setOnClickListener(v -> popWindow.dismiss());
//        popWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
//        popWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
//        popWindow.setOutsideTouchable(true);
//
//        binding.tvRoot.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
//        int popupWidth = binding.tvRoot.getMeasuredWidth();
//        int popupHeight = binding.tvRoot.getMeasuredHeight();
//
//        int[] location = new int[2];
//        anchorView.getLocationOnScreen(location);
//        popWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, (location[0] + anchorView.getWidth() / 2) - popupWidth / 2, location[1] - popupHeight);
//
//    }
//
//
//    public static void showLanguagePop(Activity activity, View anchorView) {
//
//        LayoutInflater inflater = LayoutInflater.from(activity);
//
//
//        final BaseBindingPopup<ViewBinding> popWindow = getPopupWindow(activity, TurningLanguagePopBinding.inflate(inflater));
//
//        TurningLanguagePopBinding binding = (com.xin.data.turning.databinding.TurningLanguagePopBinding) popWindow.binding;
//        List<String> list = new ArrayList<>();
//        list.add(ResUtils.s(R.string.language_type1));
//        list.add(ResUtils.s(R.string.language_type2));
//        LanguageAdapter adater = new LanguageAdapter(list);
//        String l = SpUtils.get_string(activity, SpUtils.KEY_LANGUAGE, "");
//        if (TextUtils.isEmpty(l) || l.equals("en")) {
//            adater.setIndex(0);
//        } else if (l.equals("sw")) {
//            adater.setIndex(1);
//        }
//        binding.tvInput.setText(list.get(adater.getIndex()));
//        binding.tvInput.setTag(adater.getIndex());
//        adater.setOnBtnItemClickListener(position -> {
//            binding.recyclerView.setVisibility(View.INVISIBLE);
//            binding.tvInput.setTag(position);
//            binding.tvInput.setText(list.get(position));
//        });
//        binding.recyclerView.setLayoutManager(new LinearLayoutManager(activity));
//        int d = ResUtils.d(R.dimen.dp_8);
//        binding.recyclerView.addItemDecoration(new TurningSpaceItemDecoration(d, d, activity));
//        binding.recyclerView.setAdapter(adater);
//        binding.recyclerView.setVisibility(View.INVISIBLE);
//        binding.tvOk.setOnClickListener(v -> {
//            ViewUtils.viewScale(v);
//            int positon = (int) binding.tvInput.getTag();
//            String l1 = "";
//            if (positon == 0) {
//                l1 = "en";
//            } else if (positon == 1) {
//                l1 = "sw";
//            }
//            if (!TextUtils.isEmpty(l1)) {
//                Tools.selectLanguage(activity, l1);
//                activity.recreate();
//                TurningApp.getInstance().recreateActivity();
//                PU.userBuriedPoint(PU.P205, l1);
//            }
//            popWindow.dismiss();
//        });
//        popWindow.setOnDismissListener(() -> {
//            PU.userBuriedPoint(PU.P207, "");
//            BarUtils.setNavigationBar(activity, true);
//        });
//        binding.tvInput.setOnClickListener(v -> {
//            ViewUtils.viewScale(v);
//            if (binding.recyclerView.getVisibility() != View.VISIBLE) {
//                binding.recyclerView.setVisibility(View.VISIBLE);
//            }
//        });
//
//        BarUtils.setNavigationBarColor(activity, android.R.color.white);
//
//        binding.getRoot().setOnClickListener(v -> {
//            if (Build.VERSION.SDK_INT == 35) {
//                int positon = (int) binding.tvInput.getTag();
//                String l1 = "";
//                if (positon == 0) {
//                    l1 = "en";
//                } else if (positon == 1) {
//                    l1 = "sw";
//                }
//                if (!TextUtils.isEmpty(l1)) {
//                    Tools.selectLanguage(activity, l1);
//                }
//            }
//            popWindow.dismiss();
//        });
//        binding.tvRoot.setOnClickListener(v -> {
//
//        });
//        popWindow.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);
//
//        binding.tvRoot.postDelayed(() -> {
//            BarUtils.setNavigationBar(activity, false);
//            BarUtils.setNavigationBarColor(activity, android.R.color.white);
//        }, 300);
//
//        PU.userBuriedPoint(PU.P206, "");
//
//    }
//
    @NonNull
    private static BaseBindingPopup<ViewBinding> getPopupWindow(Context context, ViewBinding nbinding) {
        return new BaseBindingPopup<>(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, context) {
            @Override
            protected ViewBinding initViewBinding(LayoutInflater inflater) {
                return nbinding;
            }
        };
    }

    public interface PopClickInterface {
        void onClickListener(String title, String value, int position, int index);
    }

    public interface PopClickInterface1 {
        void onClickListener(String title, String value);
    }

    public interface PopClickInterface2 {
        void onClickListener(KitoWalletChannel info, String data);
    }


}
